package com.javen.study.controller;

import com.javen.study.dto.UserDTO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @Author: tujw@netinnet.cn
 * @Date: 2022/11/18 15:52
 * @Description: com.javen.study.javenstudy.controller
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @GetMapping("/test")
    public void test(@RequestBody @Valid UserDTO userDTO){
        // 如果有参数校验失败，会抛出MethodArgumentNotValidException异常，然后在统一异常处理中处理
        System.out.println("接口执行成功");
    }

    @GetMapping("/test2")
    public void test2(){
        if (true) {
            throw new NullPointerException("空指针异常");
        }
    }

}
